<?php include '../../authorization_check.php' ?>
<?php include '../../checkSecretaryOnly.php' ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">
<title>View staff details</title>
<SCRIPT TYPE="text/javascript" src= "../../commonutils/util/util.js"> </SCRIPT>
</head>
<style type="text/css">
th {text-align: right}
</style>
<body>
<?php include 'top.html' ?>

<?php
  session_start();
  $programCode = $_SESSION['programCode'];
  $semesterID = $_SESSION['semesterID'];
  
?>


<?php
require_once '../../commonutils/db/DBConnectionManager.php';

$personnelID = $_POST['personnelID'];

  $sqlquery = "  select count(*) as cnt from ".
  			 " (select firstname from instructor where instructorID = ".$personnelID.
 			 " union ".	
 			 " select firstname from personnel where personnelID = ".$personnelID.")".
  			 " as tableunion ";
  

 // echo $sqlquery."<br>";
 $result = DBConnectionManager::query($sqlquery);
 $row = mysql_fetch_assoc($result);
 
 $cnt = $row['cnt'];

 if($cnt != 1)
   header('Location: SearchStaffforView.php') ;

 $sqlquery = " select firstname, lastname, title, TC_Kimlik, dateOfBirth, placeOfBirth, employmentDate from instructor where instructorID = ".$personnelID.
 			 " union ".	
 			 " select firstname, lastname, title, TC_Kimlik, dateOfBirth, placeOfBirth, employmentDate from personnel where personnelID = ".$personnelID;
 

 // echo $sqlquery."<br>";
 $result = DBConnectionManager::query($sqlquery);
 $row = mysql_fetch_assoc($result);
 
 $personnelName = $row['firstname'];
 $personnelSurname = $row['lastname'];
 $title = $row['title'];
 $citizenship = $row['TC_Kimlik'];
 $dateOfBirth = $row['dateOfBirth'];
 $placeOfBirth = $row['placeOfBirth'];	
 $employmentDate = $row['employmentDate'];
 echo "<p>";
 echo "<table border=1 cellpadding=3>";
 echo "<tr>";
 echo "<th>Personnel ID:</th>";
 echo "<td>".$personnelID."</td>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th>Name:</th>";
 echo "<td>".$personnelName."</td>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th>Surname:</th>";
 echo "<td>".$personnelSurname."</td>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th>Title:</th>";
 echo "<td>".$title."</td>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th>Citizenship Number:</th>";
 echo "<td>".$citizenship."</td>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th>Date of birth:</th>";
 echo "<td>".$dateOfBirth."</td>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th>Place of birth:</th>";
 echo "<td>".$placeOfBirth."</td>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th>Employment date:</th>";
 echo "<td>".$employmentDate."</td>";
 echo "</tr>";
 

  
?>

</table>
</p>

<?php include 'bottom.php' ?>



</body>
</html>


